<?php
class PublicAction extends Action {
	public function login(){
		if($this->isPost()&&M()->autoCheckToken($_POST)){
			if(isset($_POST['type'])&&$_POST['type']=='email'){
				$user['email'] = $_POST['in_value'];
			}else{
				$user['username'] = $_POST['in_value'];
			}			
			if(D('User')->doLogin($user,$_POST['password'])){
				redirect(C('WEB_URL').'admin.php');
			}else{
				echo 'no';
			}
		}else{
			$this->display();
		}
	}
}